import { Controller, Post, Body, Get, Req, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { CustomerServiceAuthService } from './customer-service-auth.service';
import { CustomerServiceJwtAuthGuard } from './customer-service-jwt-auth.guard';

@ApiTags('客服认证')
@Controller('customer-service/auth')
export class CustomerServiceAuthController {
  constructor(private readonly authService: CustomerServiceAuthService) {}

  @Post('register')
  @ApiOperation({ summary: '客服注册' })
  register(@Body() body: { username: string; password: string; name: string; groupId?: number; role?: 'agent' | 'supervisor' }) {
    return this.authService.register(body.username, body.password, body.name, body.groupId, body.role);
  }

  @Post('login')
  @ApiOperation({ summary: '客服登录' })
  login(@Body() body: { username: string; password: string }) {
    return this.authService.login(body.username, body.password);
  }

  @Get('me')
  @UseGuards(CustomerServiceJwtAuthGuard)
  @ApiOperation({ summary: '获取当前客服信息' })
  getProfile(@Req() req) {
    return this.authService.getProfile(req.user.sub);
  }
} 